<div class="layui-card">
  <div class="layui-card-body">
	  <div class="layui-row layui-form" id="form">
		 <div class="layui-col-lg2 layui-col-xs6">
			 <input type="text" name="keyword" placeholder="请输入用户姓名/电话" autocomplete="off" class="layui-input">
		</div>
    <div class="layui-col-lg1 layui-col-xs3">
      <select name="level">
          <option value="">用户等级</option>
            <?php foreach(c('type.user_level') as $k => $v):?>
          <option value="<?=$k?>"><?=$v?></option>
            <?php endforeach;?>
        </select>
    </div>
		<div class="layui-col-lg1 layui-col-xs1">
		  <button class="layui-btn layui-btn-normal" onclick="search()">搜索</button>
		</div>
	  </div>
	  <div class="layui-row">
			  <table class="layui-hide" lay-filter="table" id="table"></table>
	  </div>
  </div>
</div>

<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="sure">选择</a>
    <!-- <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="details">详情</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> -->
</script>
<script>
layui.use(['table','form','larry'], function(){
    var form = layui.form;
    var table = layui.table;
    var $ = layui.$;
    var larry = layui.larry;
    form.render('select');
    search = function(){
        var url = "/ordergoods/suser";
        var data = $("#form").find("[name]");
        var where = {};
        data.each(function(i,e){
            where[$(e).attr('name')] = $(e).val();
        });
        table.render({
            elem: '#table'
            ,url:url
            ,where:where
            ,method:'post'
            ,cellMinWidth:180
            ,page: true
            ,cols: [[
                //{type:'checkbox'},
                //{field:'id', title: 'ID',width:80, sort: true,title:'ID'},
                {field:'name', title: '姓名'}
                ,{field:'phone', title: '电话'}
                ,{field:'level', title: '等级'}
                ,{field:'action', title: '选择',width:250, align:'center', toolbar: '#barDemo',fixed:"right"}
            ]]
        });
    };
    search();
      //监听工具条
      table.on('tool(table)', function(obj){
        var data = obj.data;
        if(obj.event === 'edit'){
            layer.open({
                title:'编辑',
                type:2,
                area: ['100%', '100%'],
                content:'/user/edit?id='+data.id
            });
        }else if(obj.event === 'details'){
            layer.open({
                title:'我的下级会员',
                type:2,
                area: ['100%', '100%'],
                content:'/user/details?id='+data.id
            });
        }else if(obj.event === 'sure'){
          parent.suser(data);
        }
      });
});
</script>
